package com.ruoyi.bills.controller;

import com.ruoyi.bills.domain.MfBills;
import com.ruoyi.bills.service.IMfBillsService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 租客账单管理Controller
 * 
 * @author MfBills
 * @date 2025-07-22
 */
@RestController
@RequestMapping("/bills")
public class MfBillsController extends BaseController
{
    @Autowired
    private IMfBillsService mfBillsService;

    /**
     * 查询租客账单管理列表
     */
    @RequiresPermissions("bills:bills:list")
    @GetMapping("/list")
    public TableDataInfo list(MfBills mfBills)
    {
        startPage();
        List<MfBills> list = mfBillsService.selectMfBillsList(mfBills);
        return getDataTable(list);
    }

    /**
     * 导出租客账单管理列表
     */
    @RequiresPermissions("bills:bills:export")
    @Log(title = "租客账单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MfBills mfBills)
    {
        List<MfBills> list = mfBillsService.selectMfBillsList(mfBills);
        ExcelUtil<MfBills> util = new ExcelUtil<MfBills>(MfBills.class);
        util.exportExcel(response, list, "租客账单管理数据");
    }

    /**
     * 获取租客账单管理详细信息
     */
    @RequiresPermissions("bills:bills:query")
    @GetMapping(value = "/{billId}")
    public AjaxResult getInfo(@PathVariable("billId") Long billId)
    {
        return success(mfBillsService.selectMfBillsByBillId(billId));
    }

    /**
     * 新增租客账单管理
     */
    @RequiresPermissions("bills:bills:add")
    @Log(title = "租客账单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MfBills mfBills)
    {
        return toAjax(mfBillsService.insertMfBills(mfBills));
    }

    /**
     * 修改租客账单管理
     */
    @RequiresPermissions("bills:bills:edit")
    @Log(title = "租客账单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MfBills mfBills)
    {
        return toAjax(mfBillsService.updateMfBills(mfBills));
    }

    /**
     * 删除租客账单管理
     */
    @RequiresPermissions("bills:bills:remove")
    @Log(title = "租客账单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billIds}")
    public AjaxResult remove(@PathVariable Long[] billIds)
    {
        return toAjax(mfBillsService.deleteMfBillsByBillIds(billIds));
    }
}
